# coding: utf-8
# from Crypto.Cipher import AES

from django.db import models
from django.utils import timezone
from django.conf import settings
from common.models.base import BaseModel
from common.models.position import JPositionCounty, JPositionTown, JPositionVillage
from common.models.user import User


class LostFound(BaseModel):
    user = models.ForeignKey(User)

    type = models.CharField(choices=(('XR', u'寻人'), ('XW', u'寻物')), default='XW', max_length=2)
    lost_address = models.CharField(max_length=200)
    telephone = models.CharField(max_length=50)

    title = models.CharField(max_length=200)
    content = models.CharField(max_length=3000)
    is_pressing = models.BooleanField(default=False, verbose_name=u'是否紧急')
    is_found = models.BooleanField(default=False, verbose_name=u'是否找回')

    def __unicode__(self):
        return self.content

    class Meta:
        app_label = 'common'
        db_table = 'leifeng_lost_found'


class LostFoundImg(BaseModel):
    lostfound = models.ForeignKey(LostFound)
    img = models.ImageField(upload_to='static/var/', max_length=255, verbose_name=u'头像', default='static/var/default.png')


    def __unicode__(self):
        return 'img of %s'%self.lostfound.title


    class Meta:
        app_label = 'common'
        db_table = 'leifeng_lost_found_img'